<?php

/**
 * ClassName:
 * @auditor LeiJunXiang
 * @time 2024/10/22
 */

namespace app\model\user;

use think\facade\Cache;

abstract class FrameUserBase
{
    //渠道
    protected $channelId;
    //AppID
    protected $appId;
    //用户头像
    protected $userIcon;
    //用户名称
    protected $userName;
    //用户ID
    protected $userId;
    //上次登录时间
    protected $lastTime;
    //手机号
    protected $phoneNumber;


    /**
     * 生成用户id
     */
    public function createUserId()
    {
        $redis = Cache::store('redis');
        $this->userId = $redis->inc('userId');
        return $this->userId;
    }

    /**
     * @return mixed
     */
    public function getChannelId()
    {
        return $this->channelId;
    }

    /**
     * @param mixed $channelId
     */
    public function setChannelId($channelId): void
    {
        $this->channelId = $channelId;
    }

    /**
     * @return mixed
     */
    public function getAppId()
    {
        return $this->appId;
    }

    /**
     * @param mixed $appId
     */
    public function setAppId($appId): void
    {
        $this->appId = $appId;
    }

    /**
     * @return mixed
     */
    public function getUserIcon()
    {
        return $this->userIcon;
    }

    /**
     * @param mixed $userIcon
     */
    public function setUserIcon($userIcon): void
    {
        $this->userIcon = $userIcon;
    }

    /**
     * @return mixed
     */
    public function getUserName()
    {
        return $this->userName;
    }

    /**
     * @param mixed $userName
     */
    public function setUserName($userName): void
    {
        $this->userName = $userName;
    }

    /**
     * 获取用户id
     * @return mixed
     */
    public function getUserId()
    {
        if (empty($this->userId)) {
            //生成用户id
            $this->createUserId();
        }
        return $this->userId;
    }

    /**
     * @param mixed $userId
     */
    public function setUserId($userId): void
    {
        $this->userId = $userId;
    }

    /**
     * @return mixed
     */
    public function getLastTime()
    {
        return $this->lastTime;
    }

    /**
     * @param mixed $lastTime
     */
    public function setLastTime($lastTime): void
    {
        $this->lastTime = $lastTime;
    }

    /**
     * @return mixed
     */
    public function getPhoneNumber()
    {
        return $this->phoneNumber;
    }

    /**
     * @param mixed $phoneNumber
     */
    public function setPhoneNumber($phoneNumber): void
    {
        $this->phoneNumber = $phoneNumber;
    }


}